<template>
  <div class="app-container">
    <h2>月度作业费收入成本</h2>
    <!-- 搜索表单 -->
    <el-table v-loading="loading" :data="tableData" style="width: 100%" max-height="500" stripe
      :cell-style="{ padding: '20px' }" :header-cell-style="{
        background: '#cccccc!important',
        height: '100px',
        color: '#000000',
      }" class="className">
      <el-table-column prop="dept_three_name" width="180" label="辅助列" align="center" />
      <el-table-column prop="settlement_month" width="180" label="完井月份" align="center" />
      <el-table-column prop="accountName" width="180" label="是否完井" align="center" />
      <el-table-column prop="dept_id" width="180" label="分公司" align="center" />
      <el-table-column prop="dept_three_id" width="180" label="施工单位" align="center" />
      <el-table-column prop="well_no" width="180" label="井号" align="center" />
      <el-table-column prop="construction_name" width="180" label="施工类别" align="center" />
      <el-table-column prop="construction_content" width="180" label="施工内容" align="center" />
      <el-table-column prop="paymentdept_name" width="180" label="结算单位" align="center" />
      <el-table-column prop="construction_address" width="180" label="施工地点" align="center" />
      <el-table-column prop="accountName" width="180" label="开工日期" align="center" />
      <el-table-column prop="accountName" width="180" label="完工日期" align="center" />
      <el-table-column v-for="(item, index) in tableColumn" :prop="item.id" width="155" :label="item.accountName"
        align="center">
      </el-table-column>
    </el-table>
    <!-- <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
      @pagination="getList" /> -->


  </div>
</template>

<script setup>
import { ElMessage, ElMessageBox } from "element-plus";
import { ref, reactive } from "vue";
import {
  listRevenueMonthCost,
  listManagementAll,
  getManagement,
  listPaydept,
} from "@/api/cost/Operation";
import { pinyin } from "pinyin-pro";

// 字典引入
const { proxy } = getCurrentInstance();
const { payment_type, construction_flag } = proxy.useDict(
  "payment_type",
  "construction_flag"
);

//部门下拉树
const deptOptions = ref();
const constructionList = ref();
const PaydeptList = ref();
const queryPaydeptList = ref();
// 表格数据
const tableData = ref([]);
const tableColumn = ref([]);
const loading = ref(false);

// 数据总数
const total = ref(0);
const open = ref(false);
const title = ref();
const update = ref(true);
//打开弹框

// 删除的ids
const ids = ref([]);
// 单选
const single = ref(true);
// 多选
const multiple = ref(true);
const queryParams = ref({
  pageNum: 1,
  pageSize: 10,
});
// 表单字段
const formData = ref({
  accountName: "",
  wellNo: "",
  shortNo: "",
  projectType: "",
  deptId: "",
  deptThreeId: "",
  startTime: "",
  completeMonth: "",
  constructionId: "",
  constructionAddress: "",
  constructionContent: "",
  paymentdeptId: "",
});
// 表单规则
const rules = ref({
  accountName: [{ required: true, message: "名称不能为空", trigger: "blur" }],
});
// 表单重置
const reset = () => {
  formData.value = {
    accountName: "",
  };
  proxy.resetForm("postRef");
};
//获取列表列头数据
const getList = () => {
  loading.value = true;
  // 列表数据
  listRevenueMonthCost()
    .then((res) => {
      tableData.value = res.data;
      total.value = res.total;
      loading.value = false;
    })
    .catch((error) => {
      console.log(error);
    });
  // 猎头数据
  listManagementAll()
    .then((res) => {
      console.log(res);
      tableColumn.value = res.data;
    })
    .catch((error) => {
      console.log(error);
    });
  // 查询框付款单位
  listPaydept().then((res) => {
    queryPaydeptList.value = res.rows;
  });
};
/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "新增";
  update.value = false;
}
/** 编辑按钮操作 */
function handleUpdate(row) {
  reset();
  formData.value.accountName = row.accountName;
  formData.value.id = row.id;
  open.value = true;
  title.value = "修改";
  update.value = true;
}
// 取消
const cancel = () => {
  open.value = false;
  reset();
};
/**导出按钮操作 */
function handleExport() {
  proxy.download(
    "/system/management/export",
    {
      ...queryParams.value,
    },
    `项目列表.xlsx`
  );
}

//查询列表
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};
/** 多选框选中数据 */
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
getList();
</script>

<style lang="scss" scoped>
.app-container h2 {
  color: #1890FF;
  margin: 20px 0;
}

.el-row {
  margin-bottom: 20px;
}

.className :empty::before {
  content: "--";
  color: gray;
}

.search-form {
  padding-left: 20px;
}

.el-width {
  width: 340px;
}
</style>
